package tests;

import common.Utils;
import org.openqa.selenium.Alert;
import org.openqa.selenium.By;
import org.openqa.selenium.TakesScreenshot;


public class LoginPage extends Utils{
    public static String url = "http://8.138.167.159:8080/blog_login.html";
    public LoginPage() {
        super(url);
    }

    /**
     * isExistPage
     * 通过登录页面的登录模块判断网页是否存在
     */
     public void isExistPage() {
        driver.findElement(By.cssSelector("body > div.container-login > div"));
    }

    /**
     * loginSucceed
     * 通过博客列表url来验证登录是否成功
     */
    public void loginSucceed() throws InterruptedException {
        driver.findElement(By.cssSelector("#username")).sendKeys("123");
        driver.findElement(By.cssSelector("#password")).sendKeys("123456");
        driver.findElement(By.cssSelector("#submit")).click();
        String url = driver.getCurrentUrl();
        url.equals("http://8.138.167.159:8080/blog_list.html");
        driver.navigate().refresh();
    }

    /**
     * isBlogTitleExist
     * 博客名称是否存在
     */
    public void isBlogTitleExist() {
        driver.findElement(By.cssSelector("body > div.nav > span"));
    }

    /**
     * isImageExist
     * 博客头像是否存在
     */
    public void isImageExist() {
        driver.findElement(By.cssSelector("body > div.nav > img"));
    }

    /**
     * isHomePageExist
     * 主页是否存在
     */
    public void isHomePageExist() {
        driver.findElement(By.cssSelector("body > div.nav > a:nth-child(4)"));
    }
}
